//
//  NSDate+time.m
//  com.Ofans
//
//  Created by wang on 15-4-13.
//  Copyright (c) 2015年 wang. All rights reserved.
//

#import "NSDate+time.h"

@implementation NSDate (time)
//获得时间戳
//[NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]];
- (NSString *) getMyDateStrWithDateFormat:(NSString *)format
{
    NSDateFormatter *formatter=[[NSDateFormatter alloc] init];
    [formatter setDateFormat:format];
    return [formatter stringFromDate:self];
}
- (NSString *)getTimeSp
{
    NSTimeZone *zone = [NSTimeZone systemTimeZone];
    NSInteger interval = [zone secondsFromGMTForDate:self];
    NSDate *localeDate = [self dateByAddingTimeInterval:interval];
    NSLog(@"%@", localeDate);
    // 时间转换成时间戳
    NSString *timeSp = [NSString stringWithFormat:@"%ld",(long)[localeDate timeIntervalSince1970]];
    return timeSp;
}
@end
